import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class hex_dec {
    public static void main (String[] args) throws IOException{
        if (args.length<1) throw new RuntimeException ("not enough arguments");
        if (args.length>1) throw new RuntimeException ("too many arguments");
        BufferedReader reader = new BufferedReader (new FileReader (new File (args[0])));
        String line;
        while ((line = reader.readLine()) != null){          
           System.out.println (Integer.parseInt (line,16));
        }
    }
}